package cn.hl.feign;

import cn.hl.dto.StockDto;
import cn.hl.enums.GlobalExceptionCode;
import cn.hl.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;

import javax.validation.Valid;

@Component
public class StockServiceFallbackFactory implements FallbackFactory<StockService> {
    @Override
    public StockService create(Throwable throwable) {
        return new StockService() {
            @Override
            public JSONResult inboundAndOutbound(@Valid StockDto stockDto) {
                return JSONResult.error(GlobalExceptionCode.SERVICE_DEMOTE_ERROR);
            }
        };
    }
}
